import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ShopConfig } from "../../../resource/ShopConfig";
import { ECategory } from "../../../../../Message/Public/ECategory";
import { EProp } from "../../../../../Message/Public/EProp";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { BuyCommonPanel } from "./BuyCommonPanel";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SPetInfo } from "../../../../../Message/Game/SPetInfo";
import { SPetSkill } from "../../../../../Message/Game/SPetSkill";
import { SkillConfig } from "../../../resource/SkillConfig";
import { PetColor } from "../info/PetColor";
import { PetUtil } from "../info/PetUtil";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { PetSkillUtil } from "./PetSkillUtil";
import { ShopItemInfo } from "../../../resource/info/ShopItemInfo";
//class PetSkillForgetWindow
    
    export  class PetSkillForgetWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._forgetProp = ShopConfig.instance.getItemByType(ECategory._ECategoryProp, EProp._EPropPetSkillForget);
            this.setSize(305, 230);
            this.titleHeight = 28;
            this.title = Language.getString(54131);
            ObjCreate.createBg(17, 39, 270, 180, this);
            this._tipTxt = ObjCreate.createTextField("", 25, 45, 250, 50, this);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tipTxt.wordWrap = true;
            this._tipTxt.multiline = true;
            this._buyPanel = new BuyCommonPanel();
            this._buyPanel.updateByShopItemInfo(this._forgetProp);
            this._buyPanel.x = 20;
            this._buyPanel.y = 82;
            this.addChild(this._buyPanel);
            ObjCreate.createTextField(Language.getString(54132), 45, 165, 305, 20, this, GlobalStyle.textFormat2);
            this._okBtn = ObjCreate.createGButton(Language.getString(54133), 80, 190, 60, 24, this);
            this._okBtn.name = "ok";
            this._cancelBtn = ObjCreate.createGButton(Language.getString(54134), 160, 190, 60, 24, this);
            this._cancelBtn.name = "cancel";
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            this._cancelBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target as GButton;
            if (this._petInfo) 
            {
                if (loc1.name != "ok") 
                {
                    this.hide();
                }
                else if (this._petInfo && this._skill) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetForgetSkill, {"uid": this._petInfo.uid, "skillId": this._skill.skillId}));
                }
            }
            return;
        }

        public updateWindow(arg1: SPetInfo, arg2: SPetSkill): void
        {
            var loc1=null;
            this._petInfo = arg1;
            this._skill = arg2;
            if (this._petInfo && this._skill) 
            {
                loc1 = SkillConfig.instance.getInfoByName(this._skill.skillId);
                this._tip = Language.getString(54135) + PetColor.getColorName(this._petInfo) + "（" + PetUtil.getPetName(this._petInfo) + "）遗忘" + HTMLUtil.addColor(loc1.skillName, PetSkillUtil.getColorByLevel(loc1.skillLevel)) + "技能吗？";
                this._tipTxt.htmlText = "<textFormat leading=\'5\'>" + this._tip + "</textFormat>";
            }
            return;
        }

        /* internal */ /* var */_buyPanel: BuyCommonPanel;

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_cancelBtn: GButton;

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_petInfo: SPetInfo;

        /* internal */ /* var */_skill: SPetSkill;

        /* internal */ /* var */_tip: string="";

        /* internal */ /* var */_forgetProp: ShopItemInfo;
    }
